This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Load the required libraries. If you don’t have them installed, please do by running install.packages()

library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(stringr)
library(reshape2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(readr)

Load the NMR binned csv. Just adapt the path to location of your file. You can use autocompletion using the tab key

Binning_Fusarium_sh1 <- read_csv("../../data/Binning_Fusarium_matz_center_named.csv")
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_double()
## )
## ℹ Use `spec()` for the full column specifications.

Lets have a look at the first rows of this file

head(Binning_Fusarium_sh1)

OK. Be sure to have ppm on the columns and fraction numbers as rows. Now we transform the dataframe as a matrix

DTz <- as.matrix(data.frame(Binning_Fusarium_sh1))

Lets have a look at the structure of the file

str(DTz)
##  num [1:135, 1:1603] 1 2 3 4 5 6 7 8 9 10 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr [1:1603] "X." "X.1.00831" "X.0.998305" "X.0.988305" ...

Now we’ll remove the row indexes

DTz <- DTz[,-1] 

And we set the matrix row and colnames according to the ones of the df

colnames(DTz) <- colnames(Binning_Fusarium_sh1)[-1]
rownames(DTz) <- rownames(Binning_Fusarium_sh1)

Let’s transform these data in the long form

mtrx.melt <- melt(DTz, id.vars = c('sample', 'ppm'), measure.vars = 'int')
names(mtrx.melt) <- c('sample', 'ppm', 'int')

Now we can plot a quick 3Dplot to have an overview of the data

p <- plot_ly(z = ~DTz) %>% add_surface()

p

OK so now we want to remove the annoying signals corresponding to the solvents. We can check at the colunms name and note their numbers. Example its DMSO > signals at 2.5 ppm I want to delete columns 350,351 and 352.

colnames(DTz)
##    [1] "-1.00831"    "-0.998305"   "-0.988305"   "-0.978304"   "-0.968304"  
##    [6] "-0.958303"   "-0.948303"   "-0.938302"   "-0.928302"   "-0.918301"  
##   [11] "-0.9083"     "-0.8983"     "-0.888299"   "-0.878299"   "-0.868298"  
##   [16] "-0.858298"   "-0.848297"   "-0.838297"   "-0.828296"   "-0.818296"  
##   [21] "-0.808295"   "-0.798295"   "-0.788294"   "-0.778294"   "-0.768293"  
##   [26] "-0.758292"   "-0.748292"   "-0.738291"   "-0.728291"   "-0.71829"   
##   [31] "-0.70829"    "-0.698289"   "-0.688289"   "-0.678288"   "-0.668288"  
##   [36] "-0.658287"   "-0.648287"   "-0.638286"   "-0.628285"   "-0.618285"  
##   [41] "-0.608284"   "-0.598284"   "-0.588283"   "-0.578283"   "-0.568282"  
##   [46] "-0.558282"   "-0.548281"   "-0.538281"   "-0.52828"    "-0.51828"   
##   [51] "-0.508279"   "-0.498279"   "-0.488278"   "-0.478277"   "-0.468277"  
##   [56] "-0.458276"   "-0.448276"   "-0.438275"   "-0.428275"   "-0.418274"  
##   [61] "-0.408274"   "-0.398273"   "-0.388273"   "-0.378272"   "-0.368272"  
##   [66] "-0.358271"   "-0.348271"   "-0.33827"    "-0.328269"   "-0.318269"  
##   [71] "-0.308268"   "-0.298268"   "-0.288267"   "-0.278267"   "-0.268266"  
##   [76] "-0.258266"   "-0.248265"   "-0.238265"   "-0.228264"   "-0.218264"  
##   [81] "-0.208263"   "-0.198262"   "-0.188262"   "-0.178261"   "-0.168261"  
##   [86] "-0.15826"    "-0.14826"    "-0.138259"   "-0.128259"   "-0.118258"  
##   [91] "-0.108258"   "-0.0982571"  "-0.0882566"  "-0.0782561"  "-0.0682555" 
##   [96] "-0.058255"   "-0.0482545"  "-0.0382539"  "-0.0282534"  "-0.0182529" 
##  [101] "-0.00825233" "0.00174821"  "0.0117487"   "0.0217493"   "0.0317498"  
##  [106] "0.0417503"   "0.0517509"   "0.0617514"   "0.071752"    "0.0817525"  
##  [111] "0.091753"    "0.101754"    "0.111754"    "0.121755"    "0.131755"   
##  [116] "0.141756"    "0.151756"    "0.161757"    "0.171757"    "0.181758"   
##  [121] "0.191758"    "0.201759"    "0.211759"    "0.22176"     "0.231761"   
##  [126] "0.241761"    "0.251762"    "0.261762"    "0.271763"    "0.281763"   
##  [131] "0.291764"    "0.301764"    "0.311765"    "0.321765"    "0.331766"   
##  [136] "0.341766"    "0.351767"    "0.361767"    "0.371768"    "0.381769"   
##  [141] "0.391769"    "0.40177"     "0.41177"     "0.421771"    "0.431771"   
##  [146] "0.441772"    "0.451772"    "0.461773"    "0.471773"    "0.481774"   
##  [151] "0.491774"    "0.501775"    "0.511775"    "0.521776"    "0.531777"   
##  [156] "0.541777"    "0.551778"    "0.561778"    "0.571779"    "0.581779"   
##  [161] "0.59178"     "0.60178"     "0.611781"    "0.621781"    "0.631782"   
##  [166] "0.641782"    "0.651783"    "0.661784"    "0.671784"    "0.681785"   
##  [171] "0.691785"    "0.701786"    "0.711786"    "0.721787"    "0.731787"   
##  [176] "0.741788"    "0.751788"    "0.761789"    "0.771789"    "0.78179"    
##  [181] "0.79179"     "0.801791"    "0.811792"    "0.821792"    "0.831793"   
##  [186] "0.841793"    "0.851794"    "0.861794"    "0.871795"    "0.881795"   
##  [191] "0.891796"    "0.901796"    "0.911797"    "0.921797"    "0.931798"   
##  [196] "0.941799"    "0.951799"    "0.9618"      "0.9718"      "0.981801"   
##  [201] "0.991801"    "1.0018"      "1.0118"      "1.0218"      "1.0318"     
##  [206] "1.0418"      "1.0518"      "1.0618"      "1.07181"     "1.08181"    
##  [211] "1.09181"     "1.10181"     "1.11181"     "1.12181"     "1.13181"    
##  [216] "1.14181"     "1.15181"     "1.16181"     "1.17181"     "1.18181"    
##  [221] "1.19181"     "1.20181"     "1.21181"     "1.22181"     "1.23181"    
##  [226] "1.24181"     "1.25182"     "1.26182"     "1.27182"     "1.28182"    
##  [231] "1.29182"     "1.30182"     "1.31182"     "1.32182"     "1.33182"    
##  [236] "1.34182"     "1.35182"     "1.36182"     "1.37182"     "1.38182"    
##  [241] "1.39182"     "1.40182"     "1.41182"     "1.42182"     "1.43182"    
##  [246] "1.44183"     "1.45183"     "1.46183"     "1.47183"     "1.48183"    
##  [251] "1.49183"     "1.50183"     "1.51183"     "1.52183"     "1.53183"    
##  [256] "1.54183"     "1.55183"     "1.56183"     "1.57183"     "1.58183"    
##  [261] "1.59183"     "1.60183"     "1.61183"     "1.62183"     "1.63184"    
##  [266] "1.64184"     "1.65184"     "1.66184"     "1.67184"     "1.68184"    
##  [271] "1.69184"     "1.70184"     "1.71184"     "1.72184"     "1.73184"    
##  [276] "1.74184"     "1.75184"     "1.76184"     "1.77184"     "1.78184"    
##  [281] "1.79184"     "1.80184"     "1.81185"     "1.82185"     "1.83185"    
##  [286] "1.84185"     "1.85185"     "1.86185"     "1.87185"     "1.88185"    
##  [291] "1.89185"     "1.90185"     "1.91185"     "1.92185"     "1.93185"    
##  [296] "1.94185"     "1.95185"     "1.96185"     "1.97185"     "1.98185"    
##  [301] "1.99185"     "2.00186"     "2.01186"     "2.02186"     "2.03186"    
##  [306] "2.04186"     "2.05186"     "2.06186"     "2.07186"     "2.08186"    
##  [311] "2.09186"     "2.10186"     "2.11186"     "2.12186"     "2.13186"    
##  [316] "2.14186"     "2.15186"     "2.16186"     "2.17186"     "2.18186"    
##  [321] "2.19187"     "2.20187"     "2.21187"     "2.22187"     "2.23187"    
##  [326] "2.24187"     "2.25187"     "2.26187"     "2.27187"     "2.28187"    
##  [331] "2.29187"     "2.30187"     "2.31187"     "2.32187"     "2.33187"    
##  [336] "2.34187"     "2.35187"     "2.36187"     "2.37188"     "2.38188"    
##  [341] "2.39188"     "2.40188"     "2.41188"     "2.42188"     "2.43188"    
##  [346] "2.44188"     "2.45188"     "2.46188"     "2.47188"     "2.48188"    
##  [351] "2.49188"     "2.50188"     "2.51188"     "2.52188"     "2.53188"    
##  [356] "2.54188"     "2.55188"     "2.56189"     "2.57189"     "2.58189"    
##  [361] "2.59189"     "2.60189"     "2.61189"     "2.62189"     "2.63189"    
##  [366] "2.64189"     "2.65189"     "2.66189"     "2.67189"     "2.68189"    
##  [371] "2.69189"     "2.70189"     "2.71189"     "2.72189"     "2.73189"    
##  [376] "2.74189"     "2.7519"      "2.7619"      "2.7719"      "2.7819"     
##  [381] "2.7919"      "2.8019"      "2.8119"      "2.8219"      "2.8319"     
##  [386] "2.8419"      "2.8519"      "2.8619"      "2.8719"      "2.8819"     
##  [391] "2.8919"      "2.9019"      "2.9119"      "2.9219"      "2.9319"     
##  [396] "2.94191"     "2.95191"     "2.96191"     "2.97191"     "2.98191"    
##  [401] "2.99191"     "3.00191"     "3.01191"     "3.02191"     "3.03191"    
##  [406] "3.04191"     "3.05191"     "3.06191"     "3.07191"     "3.08191"    
##  [411] "3.09191"     "3.10191"     "3.11191"     "3.12192"     "3.13192"    
##  [416] "3.14192"     "3.15192"     "3.16192"     "3.17192"     "3.18192"    
##  [421] "3.19192"     "3.20192"     "3.21192"     "3.22192"     "3.23192"    
##  [426] "3.24192"     "3.25192"     "3.26192"     "3.27192"     "3.28192"    
##  [431] "3.29192"     "3.30192"     "3.31193"     "3.32193"     "3.33193"    
##  [436] "3.34193"     "3.35193"     "3.36193"     "3.37193"     "3.38193"    
##  [441] "3.39193"     "3.40193"     "3.41193"     "3.42193"     "3.43193"    
##  [446] "3.44193"     "3.45193"     "3.46193"     "3.47193"     "3.48193"    
##  [451] "3.49193"     "3.50194"     "3.51194"     "3.52194"     "3.53194"    
##  [456] "3.54194"     "3.55194"     "3.56194"     "3.57194"     "3.58194"    
##  [461] "3.59194"     "3.60194"     "3.61194"     "3.62194"     "3.63194"    
##  [466] "3.64194"     "3.65194"     "3.66194"     "3.67194"     "3.68195"    
##  [471] "3.69195"     "3.70195"     "3.71195"     "3.72195"     "3.73195"    
##  [476] "3.74195"     "3.75195"     "3.76195"     "3.77195"     "3.78195"    
##  [481] "3.79195"     "3.80195"     "3.81195"     "3.82195"     "3.83195"    
##  [486] "3.84195"     "3.85195"     "3.86195"     "3.87196"     "3.88196"    
##  [491] "3.89196"     "3.90196"     "3.91196"     "3.92196"     "3.93196"    
##  [496] "3.94196"     "3.95196"     "3.96196"     "3.97196"     "3.98196"    
##  [501] "3.99196"     "4.00196"     "4.01196"     "4.02196"     "4.03196"    
##  [506] "4.04196"     "4.05196"     "4.06197"     "4.07197"     "4.08197"    
##  [511] "4.09197"     "4.10197"     "4.11197"     "4.12197"     "4.13197"    
##  [516] "4.14197"     "4.15197"     "4.16197"     "4.17197"     "4.18197"    
##  [521] "4.19197"     "4.20197"     "4.21197"     "4.22197"     "4.23197"    
##  [526] "4.24198"     "4.25198"     "4.26198"     "4.27198"     "4.28198"    
##  [531] "4.29198"     "4.30198"     "4.31198"     "4.32198"     "4.33198"    
##  [536] "4.34198"     "4.35198"     "4.36198"     "4.37198"     "4.38198"    
##  [541] "4.39198"     "4.40198"     "4.41198"     "4.42198"     "4.43199"    
##  [546] "4.44199"     "4.45199"     "4.46199"     "4.47199"     "4.48199"    
##  [551] "4.49199"     "4.50199"     "4.51199"     "4.52199"     "4.53199"    
##  [556] "4.54199"     "4.55199"     "4.56199"     "4.57199"     "4.58199"    
##  [561] "4.59199"     "4.60199"     "4.61199"     "4.622"       "4.632"      
##  [566] "4.642"       "4.652"       "4.662"       "4.672"       "4.682"      
##  [571] "4.692"       "4.702"       "4.712"       "4.722"       "4.732"      
##  [576] "4.742"       "4.752"       "4.762"       "4.772"       "4.782"      
##  [581] "4.792"       "4.80201"     "4.81201"     "4.82201"     "4.83201"    
##  [586] "4.84201"     "4.85201"     "4.86201"     "4.87201"     "4.88201"    
##  [591] "4.89201"     "4.90201"     "4.91201"     "4.92201"     "4.93201"    
##  [596] "4.94201"     "4.95201"     "4.96201"     "4.97201"     "4.98201"    
##  [601] "4.99202"     "5.00202"     "5.01202"     "5.02202"     "5.03202"    
##  [606] "5.04202"     "5.05202"     "5.06202"     "5.07202"     "5.08202"    
##  [611] "5.09202"     "5.10202"     "5.11202"     "5.12202"     "5.13202"    
##  [616] "5.14202"     "5.15202"     "5.16202"     "5.17202"     "5.18203"    
##  [621] "5.19203"     "5.20203"     "5.21203"     "5.22203"     "5.23203"    
##  [626] "5.24203"     "5.25203"     "5.26203"     "5.27203"     "5.28203"    
##  [631] "5.29203"     "5.30203"     "5.31203"     "5.32203"     "5.33203"    
##  [636] "5.34203"     "5.35203"     "5.36203"     "5.37204"     "5.38204"    
##  [641] "5.39204"     "5.40204"     "5.41204"     "5.42204"     "5.43204"    
##  [646] "5.44204"     "5.45204"     "5.46204"     "5.47204"     "5.48204"    
##  [651] "5.49204"     "5.50204"     "5.51204"     "5.52204"     "5.53204"    
##  [656] "5.54204"     "5.55205"     "5.56205"     "5.57205"     "5.58205"    
##  [661] "5.59205"     "5.60205"     "5.61205"     "5.62205"     "5.63205"    
##  [666] "5.64205"     "5.65205"     "5.66205"     "5.67205"     "5.68205"    
##  [671] "5.69205"     "5.70205"     "5.71205"     "5.72205"     "5.73205"    
##  [676] "5.74206"     "5.75206"     "5.76206"     "5.77206"     "5.78206"    
##  [681] "5.79206"     "5.80206"     "5.81206"     "5.82206"     "5.83206"    
##  [686] "5.84206"     "5.85206"     "5.86206"     "5.87206"     "5.88206"    
##  [691] "5.89206"     "5.90206"     "5.91206"     "5.92206"     "5.93207"    
##  [696] "5.94207"     "5.95207"     "5.96207"     "5.97207"     "5.98207"    
##  [701] "5.99207"     "6.00207"     "6.01207"     "6.02207"     "6.03207"    
##  [706] "6.04207"     "6.05207"     "6.06207"     "6.07207"     "6.08207"    
##  [711] "6.09207"     "6.10207"     "6.11208"     "6.12208"     "6.13208"    
##  [716] "6.14208"     "6.15208"     "6.16208"     "6.17208"     "6.18208"    
##  [721] "6.19208"     "6.20208"     "6.21208"     "6.22208"     "6.23208"    
##  [726] "6.24208"     "6.25208"     "6.26208"     "6.27208"     "6.28208"    
##  [731] "6.29208"     "6.30209"     "6.31209"     "6.32209"     "6.33209"    
##  [736] "6.34209"     "6.35209"     "6.36209"     "6.37209"     "6.38209"    
##  [741] "6.39209"     "6.40209"     "6.41209"     "6.42209"     "6.43209"    
##  [746] "6.44209"     "6.45209"     "6.46209"     "6.47209"     "6.48209"    
##  [751] "6.4921"      "6.5021"      "6.5121"      "6.5221"      "6.5321"     
##  [756] "6.5421"      "6.5521"      "6.5621"      "6.5721"      "6.5821"     
##  [761] "6.5921"      "6.6021"      "6.6121"      "6.6221"      "6.6321"     
##  [766] "6.6421"      "6.6521"      "6.6621"      "6.67211"     "6.68211"    
##  [771] "6.69211"     "6.70211"     "6.71211"     "6.72211"     "6.73211"    
##  [776] "6.74211"     "6.75211"     "6.76211"     "6.77211"     "6.78211"    
##  [781] "6.79211"     "6.80211"     "6.81211"     "6.82211"     "6.83211"    
##  [786] "6.84211"     "6.85211"     "6.86212"     "6.87212"     "6.88212"    
##  [791] "6.89212"     "6.90212"     "6.91212"     "6.92212"     "6.93212"    
##  [796] "6.94212"     "6.95212"     "6.96212"     "6.97212"     "6.98212"    
##  [801] "6.99212"     "7.00212"     "7.01212"     "7.02212"     "7.03212"    
##  [806] "7.04212"     "7.05213"     "7.06213"     "7.07213"     "7.08213"    
##  [811] "7.09213"     "7.10213"     "7.11213"     "7.12213"     "7.13213"    
##  [816] "7.14213"     "7.15213"     "7.16213"     "7.17213"     "7.18213"    
##  [821] "7.19213"     "7.20213"     "7.21213"     "7.22213"     "7.23214"    
##  [826] "7.24214"     "7.25214"     "7.26214"     "7.27214"     "7.28214"    
##  [831] "7.29214"     "7.30214"     "7.31214"     "7.32214"     "7.33214"    
##  [836] "7.34214"     "7.35214"     "7.36214"     "7.37214"     "7.38214"    
##  [841] "7.39214"     "7.40214"     "7.41214"     "7.42215"     "7.43215"    
##  [846] "7.44215"     "7.45215"     "7.46215"     "7.47215"     "7.48215"    
##  [851] "7.49215"     "7.50215"     "7.51215"     "7.52215"     "7.53215"    
##  [856] "7.54215"     "7.55215"     "7.56215"     "7.57215"     "7.58215"    
##  [861] "7.59215"     "7.60215"     "7.61216"     "7.62216"     "7.63216"    
##  [866] "7.64216"     "7.65216"     "7.66216"     "7.67216"     "7.68216"    
##  [871] "7.69216"     "7.70216"     "7.71216"     "7.72216"     "7.73216"    
##  [876] "7.74216"     "7.75216"     "7.76216"     "7.77216"     "7.78216"    
##  [881] "7.79216"     "7.80217"     "7.81217"     "7.82217"     "7.83217"    
##  [886] "7.84217"     "7.85217"     "7.86217"     "7.87217"     "7.88217"    
##  [891] "7.89217"     "7.90217"     "7.91217"     "7.92217"     "7.93217"    
##  [896] "7.94217"     "7.95217"     "7.96217"     "7.97217"     "7.98218"    
##  [901] "7.99218"     "8.00218"     "8.01218"     "8.02218"     "8.03218"    
##  [906] "8.04218"     "8.05218"     "8.06218"     "8.07218"     "8.08218"    
##  [911] "8.09218"     "8.10218"     "8.11218"     "8.12218"     "8.13218"    
##  [916] "8.14218"     "8.15218"     "8.16218"     "8.17219"     "8.18219"    
##  [921] "8.19219"     "8.20219"     "8.21219"     "8.22219"     "8.23219"    
##  [926] "8.24219"     "8.25219"     "8.26219"     "8.27219"     "8.28219"    
##  [931] "8.29219"     "8.30219"     "8.31219"     "8.32219"     "8.33219"    
##  [936] "8.34219"     "8.35219"     "8.3622"      "8.3722"      "8.3822"     
##  [941] "8.3922"      "8.4022"      "8.4122"      "8.4222"      "8.4322"     
##  [946] "8.4422"      "8.4522"      "8.4622"      "8.4722"      "8.4822"     
##  [951] "8.4922"      "8.5022"      "8.5122"      "8.5222"      "8.5322"     
##  [956] "8.54221"     "8.55221"     "8.56221"     "8.57221"     "8.58221"    
##  [961] "8.59221"     "8.60221"     "8.61221"     "8.62221"     "8.63221"    
##  [966] "8.64221"     "8.65221"     "8.66221"     "8.67221"     "8.68221"    
##  [971] "8.69221"     "8.70221"     "8.71221"     "8.72221"     "8.73222"    
##  [976] "8.74222"     "8.75222"     "8.76222"     "8.77222"     "8.78222"    
##  [981] "8.79222"     "8.80222"     "8.81222"     "8.82222"     "8.83222"    
##  [986] "8.84222"     "8.85222"     "8.86222"     "8.87222"     "8.88222"    
##  [991] "8.89222"     "8.90222"     "8.91222"     "8.92223"     "8.93223"    
##  [996] "8.94223"     "8.95223"     "8.96223"     "8.97223"     "8.98223"    
## [1001] "8.99223"     "9.00223"     "9.01223"     "9.02223"     "9.03223"    
## [1006] "9.04223"     "9.05223"     "9.06223"     "9.07223"     "9.08223"    
## [1011] "9.09223"     "9.10224"     "9.11224"     "9.12224"     "9.13224"    
## [1016] "9.14224"     "9.15224"     "9.16224"     "9.17224"     "9.18224"    
## [1021] "9.19224"     "9.20224"     "9.21224"     "9.22224"     "9.23224"    
## [1026] "9.24224"     "9.25224"     "9.26224"     "9.27224"     "9.28224"    
## [1031] "9.29225"     "9.30225"     "9.31225"     "9.32225"     "9.33225"    
## [1036] "9.34225"     "9.35225"     "9.36225"     "9.37225"     "9.38225"    
## [1041] "9.39225"     "9.40225"     "9.41225"     "9.42225"     "9.43225"    
## [1046] "9.44225"     "9.45225"     "9.46225"     "9.47225"     "9.48226"    
## [1051] "9.49226"     "9.50226"     "9.51226"     "9.52226"     "9.53226"    
## [1056] "9.54226"     "9.55226"     "9.56226"     "9.57226"     "9.58226"    
## [1061] "9.59226"     "9.60226"     "9.61226"     "9.62226"     "9.63226"    
## [1066] "9.64226"     "9.65226"     "9.66227"     "9.67227"     "9.68227"    
## [1071] "9.69227"     "9.70227"     "9.71227"     "9.72227"     "9.73227"    
## [1076] "9.74227"     "9.75227"     "9.76227"     "9.77227"     "9.78227"    
## [1081] "9.79227"     "9.80227"     "9.81227"     "9.82227"     "9.83227"    
## [1086] "9.84227"     "9.85228"     "9.86228"     "9.87228"     "9.88228"    
## [1091] "9.89228"     "9.90228"     "9.91228"     "9.92228"     "9.93228"    
## [1096] "9.94228"     "9.95228"     "9.96228"     "9.97228"     "9.98228"    
## [1101] "9.99228"     "10.0023"     "10.0123"     "10.0223"     "10.0323"    
## [1106] "10.0423"     "10.0523"     "10.0623"     "10.0723"     "10.0823"    
## [1111] "10.0923"     "10.1023"     "10.1123"     "10.1223"     "10.1323"    
## [1116] "10.1423"     "10.1523"     "10.1623"     "10.1723"     "10.1823"    
## [1121] "10.1923"     "10.2023"     "10.2123"     "10.2223"     "10.2323"    
## [1126] "10.2423"     "10.2523"     "10.2623"     "10.2723"     "10.2823"    
## [1131] "10.2923"     "10.3023"     "10.3123"     "10.3223"     "10.3323"    
## [1136] "10.3423"     "10.3523"     "10.3623"     "10.3723"     "10.3823"    
## [1141] "10.3923"     "10.4023"     "10.4123"     "10.4223"     "10.4323"    
## [1146] "10.4423"     "10.4523"     "10.4623"     "10.4723"     "10.4823"    
## [1151] "10.4923"     "10.5023"     "10.5123"     "10.5223"     "10.5323"    
## [1156] "10.5423"     "10.5523"     "10.5623"     "10.5723"     "10.5823"    
## [1161] "10.5923"     "10.6023"     "10.6123"     "10.6223"     "10.6323"    
## [1166] "10.6423"     "10.6523"     "10.6623"     "10.6723"     "10.6823"    
## [1171] "10.6923"     "10.7023"     "10.7123"     "10.7223"     "10.7323"    
## [1176] "10.7423"     "10.7523"     "10.7623"     "10.7723"     "10.7823"    
## [1181] "10.7923"     "10.8023"     "10.8123"     "10.8223"     "10.8323"    
## [1186] "10.8423"     "10.8523"     "10.8623"     "10.8723"     "10.8823"    
## [1191] "10.8923"     "10.9023"     "10.9123"     "10.9223"     "10.9323"    
## [1196] "10.9423"     "10.9523"     "10.9623"     "10.9723"     "10.9823"    
## [1201] "10.9923"     "11.0023"     "11.0123"     "11.0223"     "11.0323"    
## [1206] "11.0423"     "11.0523"     "11.0623"     "11.0723"     "11.0823"    
## [1211] "11.0923"     "11.1023"     "11.1123"     "11.1223"     "11.1323"    
## [1216] "11.1423"     "11.1523"     "11.1623"     "11.1723"     "11.1823"    
## [1221] "11.1923"     "11.2023"     "11.2123"     "11.2223"     "11.2323"    
## [1226] "11.2423"     "11.2524"     "11.2624"     "11.2724"     "11.2824"    
## [1231] "11.2924"     "11.3024"     "11.3124"     "11.3224"     "11.3324"    
## [1236] "11.3424"     "11.3524"     "11.3624"     "11.3724"     "11.3824"    
## [1241] "11.3924"     "11.4024"     "11.4124"     "11.4224"     "11.4324"    
## [1246] "11.4424"     "11.4524"     "11.4624"     "11.4724"     "11.4824"    
## [1251] "11.4924"     "11.5024"     "11.5124"     "11.5224"     "11.5324"    
## [1256] "11.5424"     "11.5524"     "11.5624"     "11.5724"     "11.5824"    
## [1261] "11.5924"     "11.6024"     "11.6124"     "11.6224"     "11.6324"    
## [1266] "11.6424"     "11.6524"     "11.6624"     "11.6724"     "11.6824"    
## [1271] "11.6924"     "11.7024"     "11.7124"     "11.7224"     "11.7324"    
## [1276] "11.7424"     "11.7524"     "11.7624"     "11.7724"     "11.7824"    
## [1281] "11.7924"     "11.8024"     "11.8124"     "11.8224"     "11.8324"    
## [1286] "11.8424"     "11.8524"     "11.8624"     "11.8724"     "11.8824"    
## [1291] "11.8924"     "11.9024"     "11.9124"     "11.9224"     "11.9324"    
## [1296] "11.9424"     "11.9524"     "11.9624"     "11.9724"     "11.9824"    
## [1301] "11.9924"     "12.0024"     "12.0124"     "12.0224"     "12.0324"    
## [1306] "12.0424"     "12.0524"     "12.0624"     "12.0724"     "12.0824"    
## [1311] "12.0924"     "12.1024"     "12.1124"     "12.1224"     "12.1324"    
## [1316] "12.1424"     "12.1524"     "12.1624"     "12.1724"     "12.1824"    
## [1321] "12.1924"     "12.2024"     "12.2124"     "12.2224"     "12.2324"    
## [1326] "12.2424"     "12.2524"     "12.2624"     "12.2724"     "12.2824"    
## [1331] "12.2924"     "12.3024"     "12.3124"     "12.3224"     "12.3324"    
## [1336] "12.3424"     "12.3524"     "12.3624"     "12.3724"     "12.3824"    
## [1341] "12.3924"     "12.4024"     "12.4124"     "12.4224"     "12.4324"    
## [1346] "12.4424"     "12.4524"     "12.4624"     "12.4724"     "12.4824"    
## [1351] "12.4924"     "12.5024"     "12.5124"     "12.5224"     "12.5324"    
## [1356] "12.5424"     "12.5524"     "12.5624"     "12.5724"     "12.5824"    
## [1361] "12.5924"     "12.6024"     "12.6124"     "12.6224"     "12.6324"    
## [1366] "12.6424"     "12.6524"     "12.6624"     "12.6724"     "12.6824"    
## [1371] "12.6924"     "12.7024"     "12.7124"     "12.7224"     "12.7324"    
## [1376] "12.7424"     "12.7524"     "12.7624"     "12.7724"     "12.7824"    
## [1381] "12.7924"     "12.8024"     "12.8124"     "12.8224"     "12.8324"    
## [1386] "12.8424"     "12.8524"     "12.8624"     "12.8724"     "12.8824"    
## [1391] "12.8924"     "12.9024"     "12.9124"     "12.9224"     "12.9324"    
## [1396] "12.9424"     "12.9524"     "12.9624"     "12.9724"     "12.9824"    
## [1401] "12.9924"     "13.0024"     "13.0124"     "13.0224"     "13.0324"    
## [1406] "13.0424"     "13.0524"     "13.0624"     "13.0724"     "13.0824"    
## [1411] "13.0924"     "13.1024"     "13.1124"     "13.1225"     "13.1325"    
## [1416] "13.1425"     "13.1525"     "13.1625"     "13.1725"     "13.1825"    
## [1421] "13.1925"     "13.2025"     "13.2125"     "13.2225"     "13.2325"    
## [1426] "13.2425"     "13.2525"     "13.2625"     "13.2725"     "13.2825"    
## [1431] "13.2925"     "13.3025"     "13.3125"     "13.3225"     "13.3325"    
## [1436] "13.3425"     "13.3525"     "13.3625"     "13.3725"     "13.3825"    
## [1441] "13.3925"     "13.4025"     "13.4125"     "13.4225"     "13.4325"    
## [1446] "13.4425"     "13.4525"     "13.4625"     "13.4725"     "13.4825"    
## [1451] "13.4925"     "13.5025"     "13.5125"     "13.5225"     "13.5325"    
## [1456] "13.5425"     "13.5525"     "13.5625"     "13.5725"     "13.5825"    
## [1461] "13.5925"     "13.6025"     "13.6125"     "13.6225"     "13.6325"    
## [1466] "13.6425"     "13.6525"     "13.6625"     "13.6725"     "13.6825"    
## [1471] "13.6925"     "13.7025"     "13.7125"     "13.7225"     "13.7325"    
## [1476] "13.7425"     "13.7525"     "13.7625"     "13.7725"     "13.7825"    
## [1481] "13.7925"     "13.8025"     "13.8125"     "13.8225"     "13.8325"    
## [1486] "13.8425"     "13.8525"     "13.8625"     "13.8725"     "13.8825"    
## [1491] "13.8925"     "13.9025"     "13.9125"     "13.9225"     "13.9325"    
## [1496] "13.9425"     "13.9525"     "13.9625"     "13.9725"     "13.9825"    
## [1501] "13.9925"     "14.0025"     "14.0125"     "14.0225"     "14.0325"    
## [1506] "14.0425"     "14.0525"     "14.0625"     "14.0725"     "14.0825"    
## [1511] "14.0925"     "14.1025"     "14.1125"     "14.1225"     "14.1325"    
## [1516] "14.1425"     "14.1525"     "14.1625"     "14.1725"     "14.1825"    
## [1521] "14.1925"     "14.2025"     "14.2125"     "14.2225"     "14.2325"    
## [1526] "14.2425"     "14.2525"     "14.2625"     "14.2725"     "14.2825"    
## [1531] "14.2925"     "14.3025"     "14.3125"     "14.3225"     "14.3325"    
## [1536] "14.3425"     "14.3525"     "14.3625"     "14.3725"     "14.3825"    
## [1541] "14.3925"     "14.4025"     "14.4125"     "14.4225"     "14.4325"    
## [1546] "14.4425"     "14.4525"     "14.4625"     "14.4725"     "14.4825"    
## [1551] "14.4925"     "14.5025"     "14.5125"     "14.5225"     "14.5325"    
## [1556] "14.5425"     "14.5525"     "14.5625"     "14.5725"     "14.5825"    
## [1561] "14.5925"     "14.6025"     "14.6125"     "14.6225"     "14.6325"    
## [1566] "14.6425"     "14.6525"     "14.6625"     "14.6725"     "14.6825"    
## [1571] "14.6925"     "14.7025"     "14.7125"     "14.7225"     "14.7325"    
## [1576] "14.7425"     "14.7525"     "14.7625"     "14.7725"     "14.7825"    
## [1581] "14.7925"     "14.8025"     "14.8125"     "14.8225"     "14.8325"    
## [1586] "14.8425"     "14.8525"     "14.8625"     "14.8725"     "14.8825"    
## [1591] "14.8925"     "14.9025"     "14.9125"     "14.9225"     "14.9325"    
## [1596] "14.9425"     "14.9525"     "14.9625"     "14.9725"     "14.9825"    
## [1601] "14.9926"     "15.0026"
DTzred <- DTz[,-348:-352]

Now lets plot again …. Does it looks better ?

p <- plot_ly(z = ~DTzred) %>% add_surface()

p

Else repeat the previous step For this execute the following code. Be sure to run it on the previously cleaned object. In this case DTzred Be sure to check again the columns numbers sinsce these have changed

colnames(DTzred)
DTzred <- DTzred[,-348:-352]

Now that you have the cleaned data object lets have a look at the 2d map. Be patient, this one is longer to plot.

p <- plot_ly(mtrx.melt, x = ~sample, y = ~ppm, z = ~int, type = "contour",
             colors = 'YlOrRd',
             autocontour = F,
             contours = list(
               start = 10000,
               end = 1200000,
               size = 5000
             )
            )

p

If you want to plot the map with ppm on the x-axis just reverse the axis order. Play with start value (to fix the noise) and size value to fix the contour space. Change color if you wish by changing the color field. For more info on 2d contour plot with plotly check https://plot.ly/r/contour-plots/

p <- plot_ly(mtrx.melt, x = ~ppm, y = ~sample, z = ~int, type = "contour",
             autocontour = F,
             colors = 'YlOrRd',
             contours = list(
               start = 10000,
               end = 1200000,
               size = 50000
             )
            ) %>% layout(xaxis = list(autorange = "reversed"))

p

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.